
import QtQuick 1.0
//import Qt 4.7

import SocketItems 1.0
import QtMobility.systeminfo 1.1

Rectangle {
    id: main
    width: 360; height: 640
    color: "black"

    ScreenSaver {
        id: screenSaver

        Component.onCompleted: {
            setScreenSaverInhibit(true);
        }
    }

    Image {
        source:"digia_logo.png"
        smooth: true
        x: 8
        y: 0
    }

    ProgressBar {
        id: progressBar
        anchors.bottom: parent.bottom
        anchors.bottomMargin: -7
        anchors.horizontalCenter: parent.horizontalCenter
        width: parent.width * 0.5
        height: parent.height
        minimum: 0
        maximum: 10
        color: "red"
        secondColor: "blue"


    }

    /*
    Timer {
        running: true
        repeat: true
        interval: 1000
        onTriggered: {
            progressBar.value += 0.5;
        }
    }
*/

    Text {
        id: kwhText
        font.pixelSize: 30
        color: "white"
        smooth: true
        font.bold: true
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 10
        anchors.horizontalCenter: parent.horizontalCenter
        text: "0.00 kWh"
    }

    ServerSocket {
        id: serverSocket

        onServerLog: {
            //console.log(log);
        }
        onKwh: {
            //console.log(value);
            progressBar.value = parseFloat(value);
            kwhText.text = value + " kWh";
        }
    }

    Component.onCompleted: {
        serverSocket.enableClientMode();
        serverSocket.start();
    }

}
